package com.edfu.core.institutemgt.persistence.entity;

import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

@Entity
@Table(name="section", uniqueConstraints=@UniqueConstraint(columnNames={"code" , "batch_id"}))
public class SectionEntity implements IInstituteMgtEntity {
	private long id;
	private String code;
	private String title;
	private String description;
	private BatchEntity batch;
	private Set<SectionMemberEntity> members;
	
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	public long getId() {
		return id;
	}
	public void setId(long id) {
		this.id = id;
	}
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	@ManyToOne
	@JoinColumn(name="batch_id",nullable=false)
	public BatchEntity getBatch() {
		return batch;
	}
	public void setBatch(BatchEntity batch) {
		this.batch = batch;
	}
	@OneToMany(mappedBy = "section", fetch= FetchType.EAGER, cascade=CascadeType.ALL )
	public Set<SectionMemberEntity> getMembers() {
		return members;
	}
	public void setMembers(Set<SectionMemberEntity> members) {
		this.members = members;
	}
	
}
